import { axios } from '@/utils/request'
// 任务模块api

// 添加测试任务
function addTestTaskData (data, testType) {
  return axios({
    url: '/task-service/task/informal/' + testType + "/v2",
    method: 'post',
    data
  })
}

// 添加任务数据
function addTaskData (data) {
  return axios({
    url: '/task-service/task',
    method: 'post',
    data
  })
}
// 添加成品库任务
function addWarehouseTask (data) {
  return axios({
    url: '/task-service/task/warehouse',
    method: 'post',
    data
  })
}
// 删除任务数据
function delateTaskData (data, upgradeTriggerType) {
  return axios({
    url: '/task-service/task/' + upgradeTriggerType.toLowerCase() + "/v2",
    method: 'delete',
    data
  })
}

// 获取任务分页数据
function getTaskPageData (params) {
  return axios({
    url: '/task-service/task/list',
    method: 'get',
    params
  })
}
// 获取成品库任务分页数据
function getWarehouseTaskPageData (params) {
  return axios({
    url: '/task-service/task/list/warehouse',
    method: 'get',
    params
  })
}
function getTestTaskPageData (params, testType) {
  return axios({
    url: '/task-service/task/test/list/' + testType,
    method: 'get',
    params
  })
}

// 新建任务文件预处理
function fliePretreatment (data) {
  return axios({
    url: '/task-service/task/pretreatment',
    method: 'post',
    data
  })
}

// 获取任务详情
function getTaskInfor (params) {
  return axios({
    url: '/task-service/task/info',
    method: 'get',
    params
  })
}
// 任务取消
function cancelTask (data, upgradeTriggerType) {
  return axios({
    url: '/task-service/task/' + upgradeTriggerType.toLowerCase() + '/cancel/v2',
    method: 'put',
    data
  })
}
// 任务取消并删包
function cancelAndDeletePackage (data, upgradeTriggerType) {
  return axios({
    url: '/task-service/task/' + upgradeTriggerType.toLowerCase() + '/cancelAndDeletePackage/v2',
    method: 'post',
    data
  })
}
// 任务启用停用
function stopOrStart (data, upgradeTriggerType) {
  return axios({
    url: '/task-service/task/' + upgradeTriggerType.toLowerCase() + '/enable/v2',
    method: 'put',
    data
  })
}
// 催办
function processTodo (data, upgradeTriggerType) {
  return axios({
    url: '/task-service/task/urge',
    method: 'post',
    data
  })
}
// 获取某任务下车辆列表
function getTaskVehiclePageData (params) {
  return axios({
    url: '/task-service/task/vehicle/list',
    method: 'get',
    params
  })
}
// 任务状态统计
function getTaskCountByStatus (params) {
  return axios({
    url: '/web-service/task/report/countByStatus',
    method: 'get',
    params
  })
}
// 任务时间统计
function getTaskCountByDay (params) {
  return axios({
    url: '/web-service/task/report/countByDay',
    method: 'get',
    params
  })
}
// 下载车辆导入模板文件
function downloadTaskCarTpl () {
  return axios({
    url: '/task-service/task/template/excel',
    method: 'get',
    responseType: 'blob'
  })
}
// 任务车辆信息导出
function exportTaskCars (params) {
  return axios({
    url: '/task-service/task/vehicle/export',
    method: 'get',
    responseType: 'blob',
    params
  })
}
// 任务车辆信息导出
function exportTaskCarsGcy (params) {
  return axios({
    url: '/task-service/task/vehicle/exportGcy',
    method: 'get',
    responseType: 'blob',
    params
  })
}
// 追加车辆信息导出
function exportImportVehicle (params) {
  return axios({
    url: '/task-service/task/vehicle/exportImportVehicle',
    method: 'get',
    responseType: 'blob',
    params
  })
}
// 任务重发指令
function resendCommandTask (query) {
  return axios({
    url: '/task-service/task/vehicle/factory/retry',
    method: 'post',
    params: query
  })
}
// 更新任务车辆的升级状态
function upgradeStatusTaskCars (data) {
  return axios({
    url: '/task-service/task/vehicle/upgradeStatus',
    method: 'post',
    data
  })
}
// 添加任务车辆
function increaseTaskCars (data) {
  return axios({
    url: '/task-service/task/vehicle/increase',
    method: 'post',
    data
  })
}
// 任务车辆状态分组统计
function countVehicleGroupByUpdateStatus (params) {
  return axios({
    url: '/web-service/task/report/countByVehicleStatus',
    method: 'get',
    params
  })
}
// 任务车辆下ecu升级信息
function getTaskVehicleEcuList (query) {
  return axios({
      url: '/task-service/task/vehicle/ecu/list',
    method: 'get',
    params: query
  })
}

// 获取任务车辆Ecu升级情况
function getVehicleEcuDetail (params) {
  return axios({
    url: '/task-service/task/vehicle/ecu/detail',
    method: 'get',
    params
  })
}

// 获取满足条件的任务列表
function getTaskSelect (params) {
  return axios({
    url: '/task-service/task/select',
    method: 'get',
    params
  })
}

// 获取N个任务升级情况
function getUpgradeStatisticsReport (params) {
  return axios({
    url: '/web-service/task/report/upgradeStatistics',
    method: 'get',
    params
  })
}

// 任务车辆下app升级信息
function getTaskVehicleAppList (query) {
  return axios({
    url: '/task-service/task/vehicle/app/list',
    method: 'get',
    params: query
  })
}

// 获取任务车辆app升级情况
function getVehicleAppDetail (params) {
  return axios({
    url: '/task-service/task/vehicle/app/detail',
    method: 'get',
    params
  })
}

// 零件升级详情第n次列表中下载日志
function downVehicleEcuDetailLog (params) {
  return axios({
    url: '/task-service/task/vehicle/ecu/detail/log',
    method: 'get',
    params,
    responseType: 'blob'
  })
}

// 检测选择的车辆是否已被占用
function checkTaskVehicleOccupied (params) {
  return axios({
    url: '/task-service/task/vehicle/occupied',
    method: 'get',
    params
  })
}

// 获取车辆任务升级N批次列表
function getTaskVehicleDetailLists (params) {
  return axios({
    url: '/task-service/task/vehicle/detail',
    method: 'get',
    params
  })
}

// 某车辆当前任务列表
function getVehicleOccupiedDetailLists (params) {
  return axios({
    url: '/task-service/task/vehicle/occupied/detail',
    method: 'get',
    params
  })
}

// 某任务的风险列表
function getTaskVehicleRiskList (params) {
  return axios({
    url: '/task-service/task/vehicle/risk',
    method: 'get',
    params
  })
}

// 某任务的插队列表
function getTasktaskJumpList (params) {
  return axios({
    url: '/task-service/task/vehicle/taskJump',
    method: 'get',
    params
  })
}
// 查看灰度
function getTaskgrayPush (params) {
  return axios({
    url: '/task-service/task/grayPush',
    method: 'get',
    params
  })
}


// 根据任务ID获取ecu升级情况
function ecuList (taskId) {
  return axios({
    url: `/web-service/dashboard/ecuList/${taskId}`,
    method: 'post'
  })
}


// 批量删除任务车辆
function batchDeleteTaskVehicle(taskId,params) {
  return axios({
      url: '/task-service/task/vehicle/delete?taskId=' + taskId,
      method: 'delete',
      params
    })
}

// 大版本分布
function getVehicleCountReport (params) {
  return axios({
    url: '/web-service/vehicle/report/vehicleCount',
    method: 'get',
    params
  })
}
// 车辆大版本数据
function vehicleCount (data) {
  return axios({
    url: '/web-service/dashboard/vehicleCount',
    method: 'post',
    data
  })
}

// 通过车辆版本获取ecu列表信息
function getEcuVersionCountReport (params) {
  return axios({
    url: '/web-service/vehicle/report/ecuVersionCountReport',
    method: 'get',
    params
  })
}
// 通过ECU_MODULE_ID获取统计结果
function ecuVersionCountReportByEcuModuleId (data) {
  return axios({
    url: '/web-service/dashboard/ecuVersionCountReportByEcuModuleId',
    method: 'post',
    data
  })
}

// // 最新升级任务的升级方式车辆数量占比统计
// function countUpdateTypeVehicle (params) {
//   return axios({
//     url: '/web-service/task/report/countUpdateTypeVehicle',
//     method: 'get',
//     params
//   })
// }
// 升级方式
function countUpdateTypeVehicle (params) {
  return axios({
    url: '/web-service/dashboard/countUpdateTypeVehicle',
    method: 'get',
    params
  })
}


// 获取追加车辆是否需要审批
function getIsEnableAddCarAudit (params) {
  return axios({
    url: '/task-service/task/vehicle/getIsEnableAddCarAudit',
    method: 'get',
    params
  })
}
// 获取车辆版本下拉框
function vehicleVersion (data) {
  return axios({
    url: '/web-service/dashboard/vehicleVersion',
    method: 'post',
    data
  })
}

// 根据车型筛选ECU
function getEcuByModelCode (params) {
  return axios({
    url: '/web-service/dashboard/getEcuByModelCode',
    method: 'get',
    params
  })
}

// 根据ECU取ECU版本占比
function countEcuVersionByEcuModelId (data) {
  return axios({
    url: '/web-service/dashboard/countEcuVersionByEcuModelId',
    method: 'post',
    data
  })
}
// 查询任务信息--任务成功率
function taskSuccessList (data) {
  return axios({
    url: '/web-service/dashboard/taskSuccessList',
    method: 'post',
    data
  })
}
// ECU任务升级统计--ECU成功率
function upgradeEcuStatistics (data) {
  return axios({
    url: '/web-service/dashboard/upgradeEcuStatistics',
    method: 'post',
    data
  })
}
// 根据任务Id获取漏斗图数据
function getDataByTaskId (params) {
  return axios({
    url: '/web-service/dashboard/getDataByTaskId',
    method: 'get',
    params
  })
}
// 根据任务ID获取ecu
function getEcuByTaskId (params) {
  return axios({
    url: '/web-service/dashboard/getEcuByTaskId',
    method: 'get',
    params
  })
}

// 获取某任务审批历史
function getTaskAuditHistory (params) {
  return axios({
    url: '/task-service/task/audit/history',
    method: 'get',
    params
  })
}

// 自动新增策略,车辆版本
function autoCreateStrategy (testType,data) {
  return axios({
    url: `/task-service/strategy/auto/${testType}`,
    method: 'post',
    data
  })
}

// 新建智驾域版本名称
function createVersionName () {
  return axios({
    url: '/software-service/vehicleVersion/createName',
    method: 'get'
  })
}

// 研发测试任务 新建测试
function addDevelopTestTaskData (data, testType) {
  return axios({
    url: '/task-service/task/informal/' + testType + "/agg",
    method: 'post',
    data
  })
}

// 研发测试任务 复制测试
function getDevelopTaskInfor (params) {
  return axios({
    url: '/task-service/task/info/agg',
    method: 'get',
    params
  })
}

// 获取最新的测试版本号
function getNextVehicleVersion () {
  return axios({
    url: '/software-service/vehicleVersion/nextTestVehicleVersion',
    method: 'get'
  })
}
// 获取车辆详情信息
function getLoopTestTaskVehicleDetails (id) {
  return axios({
    url: '/task-service/loop-test/vehicle/' + id,
    method: 'get'
  })
}
// 循环测试任务列表分页查询
function getLoopTestTaskList (params) {
  return axios({
    url: '/task-service/loop-test/page',
    method: 'get',
    params
  })
}
// 新建循环测试任务
function addLoopTestTask (data) {
  return axios({
    url: '/task-service/loop-test',
    method: 'post',
    data
  })
}
// 取消循环测试任务
function cancelLoopTestTask (id) {
  return axios({
    url: '/task-service/loop-test/cancel/' + id,
    method: 'post'
  })
}
// 获取循环测试任务详细信息
function getLoopTestTaskDetails (id) {
  return axios({
    url: '/task-service/loop-test/' + id,
    method: 'get'
  })
}
export default {
  getTestTaskPageData,
  addTaskData,
  addWarehouseTask,
  addTestTaskData,
  delateTaskData,
  getTaskPageData,
  getWarehouseTaskPageData,
  fliePretreatment,
  getTaskInfor,
  cancelTask,
  cancelAndDeletePackage,
  stopOrStart,
  processTodo,
  getTaskVehiclePageData,
  getTaskCountByStatus,
  getTaskCountByDay,
  downloadTaskCarTpl,
  exportTaskCars,
  resendCommandTask,
  upgradeStatusTaskCars,
  increaseTaskCars,
  countVehicleGroupByUpdateStatus,
  getVehicleEcuDetail,
  getTaskVehicleEcuList,
  getTaskSelect,
  getUpgradeStatisticsReport,
  getTaskVehicleAppList,
  getVehicleAppDetail,
  downVehicleEcuDetailLog,
  checkTaskVehicleOccupied,
  getTaskVehicleDetailLists,
  getVehicleOccupiedDetailLists,
  getTaskVehicleRiskList,
  getTasktaskJumpList,
  getTaskgrayPush,
  ecuList,
  getVehicleCountReport,
  vehicleCount,
  getEcuVersionCountReport,
  ecuVersionCountReportByEcuModuleId,
  countUpdateTypeVehicle,
  // upgradeStatisticsForTask,
  exportTaskCarsGcy,
  batchDeleteTaskVehicle,
  exportImportVehicle,
  getIsEnableAddCarAudit,
  vehicleVersion,
  getEcuByModelCode,
  countEcuVersionByEcuModelId,
  taskSuccessList,
  upgradeEcuStatistics,
  getDataByTaskId,
  getEcuByTaskId,
  getTaskAuditHistory,
  autoCreateStrategy,
  createVersionName,
  addDevelopTestTaskData,
  getDevelopTaskInfor,
  getNextVehicleVersion,
  getLoopTestTaskList,
  addLoopTestTask,
  cancelLoopTestTask,
  getLoopTestTaskVehicleDetails,
  getLoopTestTaskDetails
}
